﻿using System.Net.Mail;
using Business.Entities.Email;

namespace Data.ServiceAgents.Mailing
{
    public class EmailService
    {
        protected MailMessage oMailMessage;
        protected SmtpClient oSmtpClient;

        public EmailService()
        {
            this.oMailMessage = new MailMessage();
            this.oSmtpClient = new SmtpClient();
        }

        private void sendMail(Message oMessage)
        {
            this.oMailMessage.To.Add(new MailAddress(oMessage.To));
            this.oMailMessage.Subject = oMessage.Subject;
            this.oMailMessage.Attachments.Add(new Attachment(oMessage.AttachmentPath));
            this.oMailMessage.Body = oMessage.Body;
            this.oMailMessage.IsBodyHtml = oMessage.HtmlBody;

            this.oSmtpClient.Send(oMailMessage);
        }
    }
}
